package net.sxnic.ugr.permission.action;

import net.sxnic.comm.utils.PropertyUtil;

import org.apache.commons.lang3.StringUtils;
import org.hibernate.criterion.Criterion;
import org.hibernate.criterion.Restrictions;
import org.springframework.beans.factory.annotation.Autowired;
import net.sxinfo.core.dao.Page;
import net.sxinfo.core.dao.hibernate3.HibernateCriteria;
import net.sxinfo.core.dao.hibernate3.HibernateDaoUtils;
import net.sxinfo.core.dao.hibernate3.HibernateOrder;
import net.sxinfo.core.util.WebUtils;
import net.sxnic.ugr.permission.Permission;

/**
 * 
 * Introduction：
 * @author 张国业
 * create date : 2013-4-15
 */
@SuppressWarnings("serial")
public class Browse extends PermissionAction {

	public String execute() throws Exception {
		try {
			checkRoles(Permission.SYSTEM_ADMIN);
			int pageNumber = WebUtils.getPageNumber(request);
			int pageSize = PropertyUtil.findTableSize("firstbrowse.tabsize");

			HibernateOrder infoCodeOrder = HibernateDaoUtils
					.createHibernateOrder("id", true);
			HibernateCriteria hc = new HibernateCriteria().add(infoCodeOrder);

			Criterion dc = null;

			if (StringUtils.isNotBlank(resId)) {

				dc = Restrictions.eq("res.id", resId);
				hc.add(dc);
			}
			
			resList = resourceManager.getAll();

			permissions = permissionManager.getPageByCriteria(pageNumber,
					pageSize, hc);

		} catch (Exception e) {
			e.printStackTrace();
		}

		return SUCCESS;
	}

	
	 
    
}